/*
 * @Author: Erwin
 * @Date: 2022-04-22 17:01:57
 * @LastEditors: your name
 * @LastEditTime: 2022-07-05 11:24:01
 * @Description:
 */

import { fileURLToPath, URL } from 'url'
import { loadEnv } from 'vite'
import { server } from './dev-server.config'
import createVitePlugins from './dev-kit/vite'
const CWD = process.cwd()
export default ({ command, mode }) => {
	const { VITE_BASE_URL, VITE_APP_OUT_DIR } = loadEnv(mode, CWD)
	return {
		base: VITE_BASE_URL,
		plugins: createVitePlugins(),
		server,
		optimizeDeps: {
			include: [],
			exclude: [],
		},

		resolve: {
			alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
        'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
			},
		},
		build: {
			outDir: VITE_APP_OUT_DIR,
			target: ['es2015', 'chrome64'],
			assetsDir: 'assets',
			minify: 'terser',
			terserOptions: {
				compress: {
					keep_infinity: true,
					drop_console: mode === 'production',
				},
			},
		},
	}
}
